package com.sk.sqd.company;

import java.util.ArrayList;
import java.util.List;

/**
 * 具体公司
 */
public class ConcreteCompany extends Company {

    // 存储下级节点
    private List<Company> childList = new ArrayList<>();

    @Override
    public void add(Company company) {
        childList.add(company);
    }

    @Override
    public void remove(Company company) {
        childList.remove(company);
    }

    @Override
    public void display() {
        System.out.println(name);
        childList.forEach(Company::display);
    }

    @Override
    public void working() {
        childList.forEach(Company::working);
    }

    public ConcreteCompany(String name) {
        this.name = name;
    }
}
